package com.sky.controller.user;

import com.sky.service.user.PrePayUrlNotifyService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;

/**
 * 预支付url通知接口
 *
 * @author zgp
 * @version V1.0
 * @date 2025-02-03 18:26
 */
@Slf4j
@Api(tags = "")
@RestController
@RequestMapping("/user/prePayUrl")
public class PrePayUrlNotifyController {
    @Autowired
    private PrePayUrlNotifyService prePayUrlNotifyService;

    /**
     * 创建 SSE 连接，推送支付二维码 URL
     */
    @GetMapping(value = "/sse", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
    public SseEmitter handleSse() {
        return prePayUrlNotifyService.pushNotify();
    }
}
